
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@

CC = @CC@
LD = $(CC)
AS = $(CC)
INSTALL = @INSTALL@

CFLAGS = @CFLAGS@
# NOTE if get; undefined reference to 'vid_screenshot'
# screen shot support is not in the port/backend.
# Add -DGNUBOY_NO_SCREENSHOT define below.
# SDL port includes screen shot support already.
#CFLAGS += -DGNUBOY_NO_SCREENSHOT

LDFLAGS = $(CFLAGS) @LDFLAGS@
ASFLAGS = $(CFLAGS)

TARGETS = @TARGETS@

ASM_OBJS = @ASM_OBJS@

SYS_DEFS = @DEFS@ @ENDIAN@ @ASM@ @SYS_DEFS@
SYS_OBJS = sys/nix/nix.o $(ASM_OBJS)
SYS_INCS = -I/usr/local/include @XINCS@ -I./sys/nix

## Requirements for (optional) .zip support
## Disable with GNUBOY_NO_MINIZIP defined
USE_MINIZIP = True
ifdef USE_MINIZIP
	SYS_OBJS += unzip/unzip.o unzip/ioapi.o
	LDFLAGS = -lz
else
	CFLAGS += -DGNUBOY_NO_MINIZIP
endif

FB_OBJS = @FB_OBJS@ @JOY@ @SOUND@
FB_LIBS = 

SVGA_OBJS = sys/svga/svgalib.o sys/pc/keymap.o @JOY@ @SOUND@
SVGA_LIBS = -L/usr/local/lib -lvga

SDL_OBJS = sys/sdl/sdl.o sys/sdl/keymap.o sys/sdl/SFont.o
SDL_LIBS = @SDL_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@

X11_OBJS = sys/x11/xlib.o sys/x11/keymap.o @JOY@ @SOUND@
X11_LIBS = @XLIBS@ -lX11 -lXext

all: $(TARGETS)

include Rules

fbgnuboy: $(OBJS) $(SYS_OBJS) $(FB_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(FB_OBJS) -o $@ $(FB_LIBS)

sgnuboy: $(OBJS) $(SYS_OBJS) $(SVGA_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SVGA_OBJS) -o $@ $(SVGA_LIBS)

sdlgnuboy: $(OBJS) $(SYS_OBJS) $(SDL_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SDL_OBJS) -o $@ $(SDL_LIBS)

sys/sdl/sdl.o: sys/sdl/sdl.c
	$(MYCC) $(SDL_CFLAGS) -c $< -o $@

sys/sdl/keymap.o: sys/sdl/keymap.c
	$(MYCC) $(SDL_CFLAGS) -c $< -o $@

sys/sdl/SFont.o: sys/sdl/SFont.c
	$(MYCC) $(SDL_CFLAGS) -c $< -o $@

xgnuboy: $(OBJS) $(SYS_OBJS) $(X11_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(X11_OBJS) -o $@ $(X11_LIBS)

install: all
	$(INSTALL) -d $(bindir)
	$(INSTALL) -m 755 $(TARGETS) $(bindir)

clean:
	rm -f *gnuboy gmon.out *.o unzip/*.o sys/*.o sys/*/*.o asm/*/*.o

distclean: clean
	rm -f config.* sys/nix/config.h Makefile




